* ----------------------- Figure 3: Parallel trends: Treated versus control BDCs
* ---------------------------------------------- Panel (A) Mutual fund ownership

use "$data_path/database_bdc_level_synthetic.dta", clear
	   
foreach q in "1" "2" "3" "4" {
forval y = 2011/2017 {

gen ind_post_temp = 0 
replace ind_post_temp = 1 if filingdateqtr == yq(`y',`q')

gen int`y'q`q' = ind_post_temp*ind_treated_bdc
drop ind_post_temp 
}
}

foreach var in "mutown_perc" {

reghdfe `var'          int2012q1 int2012q2 int2012q3 int2012q4 ///
                       int2013q1 int2013q2 int2013q3 int2013q4 ///
                                           int2014q3 int2014q4 ///
					   int2015q1 int2015q2 int2015q3 int2015q4 ///
			           int2016q1 int2016q2 int2016q3 int2016q4 ///
					   lag_assets_total_ln lag_debt_to_assets_ratio lag_int_inc_net_avg_assets, ///
			            absorb(bdc_ticker_num filingdateqtr) noomit 
est sto def 

coefplot def, keep(int2012q1 int2012q2 int2012q3 int2012q4  ///
                   int2013q1 int2013q2 int2013q3 int2013q4  ///
                                       int2014q3 int2014q4  ///
				   int2015q1 int2015q2 int2015q3 int2015q4  ///
			       int2016q1 int2016q2 int2016q3 int2016q4) ///
                   vert nokey  addplot(line @b  @ul1 @ll1 @at, lcolor(navy maroon maroon) ///
                   clpattern(solid dash dash)) ///
                   graphregion(color(white)) ///
				   ciopts( lcolor(white)) ///
                   mfcolor(white)   ///
				   mcolor(navy)  ///
                   xtitle("", size(5)) ytitle("Coefficient Estimate", size(5))  levels(95) ///
				   ylabel(, labsize(5)) ///
				   yline(0, lcolor(black) lpattern(solid))  ///
				   xline(8.5, lcolor(black) lpattern(longdash)) ///
                   coeflabels(int2012q1 = " " int2012q2 = " " int2012q3 = " " int2012q4 = " " ///
				              int2013q1 = " " int2013q2 = " " int2013q3 = " " int2013q4 = " " ///
							                                  int2014q3 = "Index Exclusion" int2014q4 = " " ///
				              int2015q1 = " " int2015q2 = " " int2015q3 = " " int2015q4 = " " ///
				              int2016q1 = " " int2016q2 = " " int2016q3 = " " int2016q4 = " " ) ///
				   xlabel(, labsize(5)) 	  
graph export "$figures_path/figure3_`var'.eps", replace

}	

